package www.Zheng;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;

/**
 * @Title: Demo4
 * @Author 郑雨杭
 * @Package www.Zheng
 * @Date 2024/7/7 22:44
 * @description:字节输入流
 */
public class Demo4 {
    public static void main(String[] args) {
        try(InputStream stream = new FileInputStream("D:\\gitee仓库\\java\\File\\test.txt")) {
            byte[] rem = new byte[10];
            while(true){
                int n = stream.read(rem);
                if (n == -1) {
                    break;
                }else{
                    for (int i = 0; i < n; i++) {
                        System.out.printf("%x\n",rem[i]);
                    }
                }
            }
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
